﻿
using System.Collections.Generic;
using System.Data;
using System;
namespace ZHDJ.MobileInterface
{
    public partial class UserOnlyValidate : AbstractBasePage
    {
        protected override OutParam BusinessProcess<InParam, OutParam>(InParam inParam)
        {
            // 业务逻辑返回的响应对象  
            MembersOnlyValidateOutParam result = new MembersOnlyValidateOutParam();
            MembersOnlyValidateInParam param = new MembersOnlyValidateInParam();
            string logMsg = "";
            bool isFlag = true;
                 
            try
            {
                param = inParam as MembersOnlyValidateInParam;
                if (string.IsNullOrEmpty(param.user_name))
                {
                    result.code = "0";
                    result.desc = "用户名不能为空";

                    isFlag = false;
                }
                if (isFlag)
                {
                    if (InterfaceHelper.CheckLoginIDCount(param.user_name.Trim()))
                    {
                        result.data.is_only = "0";
                    }
                    else
                    {
                        if (InterfaceHelper.CheckLoginIDCountEx(param.user_name))
                            result.data.is_only = "0";
                        else
                            result.data.is_only = "1";
                    }
                } 

                logMsg = result.desc;
            }
            catch (Exception ex)
            {
                result.code = "0";
                result.desc = "操作异常，多次出现请联系管理员"; 
                logMsg = ex.Message + ":" + ex.StackTrace;
            }

            CommonUtils.InsertMobileInterfaceLog(SystemCode +"-MembersOnlyValidate", SerializeHelper.JsonSerializer<MembersOnlyValidateInParam>(param), logMsg); 
            return result as OutParam;
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (string.Compare(Request.QueryString["Safe"], "False", true) == 0)
                ProcessRequest<MembersOnlyValidateInParam, MembersOnlyValidateOutParam>();
            else
                SafeProcessRequest<MembersOnlyValidateInParam, MembersOnlyValidateOutParam>();
        }
    }

    #region 请求参数
    public class MembersOnlyValidateInParam
    {
        /// <summary>
        ///	用户名	必须
        /// </summary>
        public string user_name
        { get; set; }  
    }
    #endregion

    #region 结果参数
    public class MembersOnlyValidateOutParam
    {
        public MembersOnlyValidateOutParam()
        {
            code = "1";
            desc = "操作成功";
            data = new MembersOnlyValidateOutData();
        }

        /// <summary>
        /// 返回结果 具体见接口返回对照码 1	成功 0	失败 2	请求非法 加密结果和传入的MD5字符串进行比较，如果相同则执行接口操作，否则返回1001错误响应码
        /// </summary>
        public string code
        { get; set; }

        /// <summary>
        /// 结果描述 成功和失败都需要
        /// </summary>
        public string desc
        { get; set; }

        public MembersOnlyValidateOutData data
        { get; set; }
    }

    public class MembersOnlyValidateOutData
    {
        /// <summary>
        ///	是否唯一  1：是，0：否
        /// </summary>
        public string is_only
        { get; set; }
    }
    #endregion 
}